local skel = fk.CreateSkill {
  name = "efengqi__wansha",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["efengqi__wansha"] = "完杀",
  [":efengqi__wansha"] = "锁定技，你的回合内，除你和处于濒死状态的角色以外的所有角色的【桃】和【无懈可击】均视为【杀】。",

  ["$efengqi__wansha1"] = "神仙难救，神仙难救啊。",
  ["$efengqi__wansha2"] = "我要你三更死，谁敢留你到五更！",
}

skel:addEffect("filter", {
  mute = true,
  card_filter = function(self, card, player)
    local current = table.find(Fk:currentRoom().alive_players, function(p) return p.phase ~= Player.NotActive end)
    if player and current and current ~= player and current:hasSkill(skel.name) and not player.dying then
      return card.trueName == "peach" or card.trueName == "nullification"
    end
  end,
  view_as = function (self, player , card)
    local c = Fk:cloneCard("slash", card.suit, card.number)
    c.skillName = skel.name
    return c
  end,
})

--- 进、出濒死，得到、失去技能都得更新一次牌
skel:addEffect(fk.EnterDying, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and player.phase ~= Player.NotActive
  end,
  on_refresh = function (self, event, target, player, data)
    player:broadcastSkillInvoke(skel.name)
    player.room:notifySkillInvoked(player, skel.name, "offensive")
    for _, p in ipairs(player.room.alive_players) do
      p:filterHandcards()
    end
  end,
})

skel:addEffect(fk.AfterDying, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(skel.name, true) and player.phase ~= Player.NotActive
  end,
  on_refresh = function (self, event, target, player, data)
    for _, p in ipairs(player.room.alive_players) do
      p:filterHandcards()
    end
  end,
})

skel:addLoseEffect(function (self, player, is_death)
  for _, p in ipairs(player.room.alive_players) do
    p:filterHandcards()
  end
end)

skel:addAcquireEffect(function (self, player, is_start)
  for _, p in ipairs(player.room.alive_players) do
    p:filterHandcards()
  end
end)

return skel
